#!/usr/bin/perl

use Web::Scraper;
use URI;
use YAML;

my $domein = 'http://www.ikea.com';
my $url = 'http://www.ikea.com/jp/ja/catalog/news/range/';

my $scraper = scraper {
   process '//title','title' => 'TEXT'; 
   process '//div[@class="productNavigation"]//div[@class="productItem"]/span[@class="prodName"]','products[]' =>
       scraper {
            process '//a','category'   => 'TEXT';
            process '//a','list'       => sub{
                                            my $cat_url = $domein.$_->attr_get_i('href');
                                            scraper {
                                                process '//div[@class="productPadding"]','data[]' => 
                                                    scraper {
                                                        process '//a','link'                         => '@HREF';
                                                        process '//img','image'                      => '@SRC';
                                                        process '//span[@class="prodName"]','name'   => 'TEXT';
                                                        process '//span[@class="prodDesc"]','dec'    => 'TEXT';
                                                        process '//span[@class="prodPrice"]','price' => 'TEXT';
                                                    };
                                               result qw/data/
                                            }->scrape(URI->new($cat_url));
                                       };
      };
   result qw/title products/
}->scrape(URI->new($url));

print YAML::Dump($scraper);

__END__

